var referrer = "";//登录后返回页面
referrer = document.referrer;
if (!referrer) {
	try {
		if (window.opener) {                
			// IE下如果跨域则抛出权限异常，Safari和Chrome下window.opener.location没有任何属性              
			referrer = window.opener.location.href;
		}  
	} catch (e) {
	}
}

//按键盘Enter键即可登录
$(document).keyup(function(event){
	if(event.keyCode == 13){
		login();
	}
});

/**
 * 登录
 */
function login() {
	var phone = $("#phone").val();
	var loginPassword = $("#loginPassword").val();
	// 如果为空则光标移到对应输入框
	if (phone == null || phone == "") {
		$("#phone").focus();
		return;
	}else if (loginPassword == null || loginPassword == "") {
		$("#loginPassword").focus();
		return;
	}
	$.post("/005-money-web/loan/page/doLogin",{ phone:phone, loginPassword: $.md5(loginPassword) },
		function (data) {
			if (data.code == 1) {
				// 取出路径里面的redirectURL
				var redirectURL = window.location.search.split("redirectURL=")[1];
				if (redirectURL != null) {
					window.location.href = redirectURL;
				}else {
					window.location.href = rootPath + "/index";
				}
			}else{
				alert(data.message);
			}
		});


}
